package cn.simple.manager.Repository;

import cn.simple.manager.todo.BannerStorage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface BannerResponsitory extends JpaRepository<BannerStorage, String> {

    @Query(value = "select * from bannerStorage where media_Id = ?1",nativeQuery = true)
    List<BannerStorage> ListfindAllByMediaid(List<String> mediaids);


    @Query(value = "select * from (select * from bannerStorage where type = 'Wechat_news' order by update_time limit 3)\n" +
            "UNION ALL\n" +
            "select * from (select * from bannerStorage where type = 'http' order by update_time limit 3)" , nativeQuery = true)
    List<BannerStorage> selectHotWechatOrBanner();
}
